Sample Scripts |
The following are some sample scripts to show how Beyond Compare can use scripts. You can either use these scripts as is or model your own scripts after them. Here is a basic script which copies all of the newer and orphaned files from one folder to another, using a previously created session: load "Sync Laptop" sync update:left->right
Synching two folders Here is a more advanced script which syncs two specific folders using advanced filters. This works the same as loading the folders in a Folder Compare session and performing a "Mirror Left to Right" folder synchronization. # Turn logging on log normal "C:\My Documents\Webpage\Synclog.txt" # Load the default session and exclude all but certain file types load <default> filter "*.html;*.htm;*.png;*.jpg" # Load the base folders load "C:\My Documents\Webpage" "ftp://user@ftp.some-isp.com/webroot" # Copy different files left to right, delete orphans on right sync mirror left->right
Comparing two files by name This script compares two files by name. file-report layout:side-by-side & options:display-mismatches & output-to:%3 %1 %2
A sample command line, calling the above script: bcompare.exe @GenerateReport.txt Mine\Sample.txt Theirs\Sample.txt Report.txt
Note An ampersand (&) at the end of a line means that the command continues on the next line. Note %1, %2, and %3 refer to the 1st, 2nd and 3rd command line argument, respectively. Generating a report This script compares two files by name and generates an html report showing differences with context: file-report layout:side-by-side & options:ignore-unimportant,display-context & output-to:%3 output-options:html-color %1 %2
Keeping a web site in sync This script keeps a web site in sync with development files. #log the script log verbose append:"c:\website updates.txt" #set the comparison criteria criteria timestamp size #load source and target load c:\website ftp://web@vmscooter-linux/html/testing #filter to only include source files, ignore CVS subfolders filter "*.htm;*.html;*.php;*.jpg;*.gif;-CVS\" #Sync the local files to the web site, creating empty folders sync create-empty mirror:lt->rt
Performing a rules-based comparison and logging results to a file This script logs the script results to a file that uses the current date as part of the name. The variable %date% is expanded by the script in the format 2004-10-13 on U.S. English systems, on other systems it will match the system locale. It performs a rules-based comparison of Pascal source files and generates a text report of mismatches. #log to a file of the form log2004-10-13.txt #the exact format depends on your regional and language settings log verbose append:projectlog%date%.txt #compare the text contents of the files criteria rules-based #only compare delphi source files, ignore the archive folder filter "*.pas;*.dfm;*.dpr;*.inc;-archive\" load s:\project\chris s:\project\tim folder-report layout:summary & options:display-mismatches,column-attributes,column-timestamp,column-size & output-to:projectreport.txt
Comparing current folder state to a snapshot This script compares the current state of a folder to a snapshot from the last time updates were sent out. Then it copies the changed and new files to a zip file and updates the snapshot of the folder. option confirm:yes-to-all #compare using crc criteria crc #load current files against snapshot from the last patch load "c:\folder" "c:\folder.bcss" #expand to affect subfolders and files expand all #select updated files select lt.diff.files lt.orphan.files #copy changes to a zip file copyto lt path:relative "c:\folderchanges.zip" #update the snapshot snapshot save-crc lt output:"c:\folder.bcss"
Generating a report of differences This script generates a report of only differences. #set up basic comparison features criteria timestamp:2sec #filter out log files filter "-\dir1\dir2\*.log" #load first comparison load \\srv1\share \\srv2\share #compare files with timestamp differences select newer.files older.files #generate a report of the differences folder-report layout:summary options:display-mismatches output-to:C:\report.txt
|